# 2024/4/7 下午7:44 HFL
# 导包
import time
from selenium import webdriver
from selenium.webdriver.common.by import By

from Financial_operation.create_phone import phone

# 创建浏览器驱动对象
driver = webdriver.Chrome()
# 浏览器窗口最大化
driver.maximize_window()
# 输入URL，打开web页面
driver.get('http://121.43.169.97:8081/common/member/reg')
# 输入手机号
driver.find_element(By.ID,'phone').send_keys(phone())
# 输入密码
driver.find_element(By.ID,'password').send_keys('a123456')
# 输入验证码
driver.find_element(By.ID,'verifycode').send_keys('8888')
time.sleep(1)
# 点击获取短信验证码
driver.find_element(By.ID,'get_phone_code').click()
# 等待0.5秒
time.sleep(1)
# 输入验证码
driver.find_element(By.ID,'phone_code').send_keys('666666')
time.sleep(1)
# 点击注册按钮
driver.find_element(By.CSS_SELECTOR,'[value="免费注册"]').click()
time.sleep(1)
# 获取文本进行断言
res = driver.find_element(By.XPATH,'/html/body/div[1]/div[2]/div[2]/div/div/h1').text
time.sleep(1)
assert res in '注册成功！'
# 强制等待
time.sleep(2)
# 关闭浏览器对象
driver.quit()
